package com.w2cx.selenium.operate;

import com.w2cx.selenium.base.DriverBase;
import com.w2cx.selenium.page.POI_CateManagePage;
import org.openqa.selenium.WebElement;

import java.util.ArrayList;
import java.util.List;

public class POI_CateManageOperate {
    DriverBase driver;
    POI_CateManagePage pcmp;
    public POI_CateManageOperate(DriverBase driver){
        this.driver = driver;
        pcmp = new POI_CateManagePage(driver);
    }


    //点击“基础数据管理”菜单
    public void clickBaseDataManageMenu(){
        pcmp.click(pcmp.getBaseDataManageMenu());
    }

    //点击“POI分类管理”菜单
    public void clickPoiCateManageMenu(){
        pcmp.click(pcmp.getPoiCategoryManageMenu());

    }



    //点击“添加”按钮
    public void clickPoiAddBtn(){
        pcmp.click(pcmp.getPoiAddBtn());

    }

    //输入分类名称
    public void inputPoiName(String poiName){
       pcmp.sendKeys(pcmp.getPoiNameInput(),poiName);
    }

    //点击“保存”按钮
    public void clickPoiAddSave(){
        pcmp.click(pcmp.getPoiAddSaveBtn());
    }

    //获取列表
    public List<WebElement> getPoiCateList(){
       return pcmp.getPoiCateList();
    }

    //点击删除按钮
    public void clickPoiDelBtn(String poiName){

        ArrayList<WebElement> list = (ArrayList<WebElement>) pcmp.getPoiCateList();
        for (int i=0;i<list.size();i++){
            WebElement element = list.get(i);
            if(element.getText().contains(poiName)){
                pcmp.click(pcmp.getPoiDelBtn(element));
            }
        }
    }

    //点击确定按钮
    public void clickPoiDelConfirmBtn(){
        pcmp.click(pcmp.getPoiDelConfirmBtn());
    }






}
